package Exercise;

import java.util.*;

public class Doudizhu {
    public static void main(String[] args) {
        //组牌-----------
        HashMap<Integer, String> poker = new HashMap<>();//内容
        ArrayList<Integer> pokerIndex= new ArrayList<>();//索引
        List<String> colors = Arrays.asList("♥","♠","♣","♦");//表示花色
        //牌面-------
        List<String> numbers= Arrays.asList("2","3","4","5","6","7","8","9","10",
                "J","Q","K","A");
        int index=0;
        poker.put(index,"大王");
        pokerIndex.add(index);
        index++;
        poker.put(index,"小王");
        pokerIndex.add(index);
        index++;
        for (String number:numbers){
            for (String color:colors){
                poker.put(index,color+number);
                pokerIndex.add(index);
                index++;
            }
        }
        //所有的牌是-------
         System.out.println("poker = " + poker);
        //洗牌--------
        Collections.shuffle(pokerIndex);
        //发牌--------
        ArrayList<Integer> player1 = new ArrayList<>();
        ArrayList<Integer> player2 = new ArrayList<>();
        ArrayList<Integer> player3 = new ArrayList<>();
        ArrayList<Integer> diPai = new ArrayList<>();
        for (int i = 0; i <pokerIndex.size() ; i++) {
            Integer in = pokerIndex.get(i);
            if (i>=51){
                diPai.add(in);
            }else if (i%3==0){
                player1.add(in);
            }else if (i%3==1){
                player2.add(in);
            }else if (i%3==2){
                player3.add(in);
            }
        }
        //整理牌面-----
        Collections.sort(player1);
        Collections.sort(player2);
        Collections.sort(player3);
        //看牌------
        lookPoker("aa",poker,player1);
        lookPoker("bb",poker,player2);
        lookPoker("cc",poker,player3);
        lookPoker("底牌",poker,diPai);
    }
    public static void lookPoker(String name,HashMap<Integer, String> poker, ArrayList<Integer> player){
        System.out.println(name+"的牌是：");
        for (Integer key:player){
            String s = poker.get(key);
            System.out.print("" + s);
        }
        System.out.println();
    }
}
